package bojan.robots.motion;

import java.util.Collection;

import sim.util.Double2D;

public class DistanceEvaluator {

//	Collection<Double2D> alternative;
//	Double2D goal;
//	public DistanceEvaluator(Collection<Double2D> alternative, Double2D goal) {
//		super();
//		this.alternative = alternative;
//		this.goal = goal;
//	}
//	
//	public Double2D nextMove() { 
//		Double2D a = closest(alternative, goal);
//		alternative.remove(a);
//		return a                ;
//	}

	
	
	public Double2D closest(Collection<Double2D> alternatives, Double2D reference) {		
		Double2D closest = null;
		double actual = Double.MAX_VALUE;
		for (Double2D alternative : alternatives) {
			if (alternative.distance(reference) < actual) {
				actual = alternative.distance(reference);
				closest = alternative;
			}
		}
		return closest;
	}
}
